/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sistemperpustakaan.utility;

import com.conn.SettingUI;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author EKo
 */
public class DbUtility {

    Connection connection;
    private SettingUI jConfig;

    public Connection getConnection(){
        jConfig = new SettingUI(null, true);
        jConfig.makeConnect();
        connection = jConfig.getConnection();
        
//        String server = "127.0.0.1";
//        String name = "root";
//        String password = "";
//   		try {
//      		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//         	try {
////         		String url = "jdbc:odbc:DbPerpustakaan_MSSQL";
//         		String url = "jdbc:odbc:"+server;
//            	connection = DriverManager.getConnection(url,name,password);
//         	} catch(SQLException ex) {
//         		System.exit(0);
//			}
//		} catch(ClassNotFoundException ex) {
//     		System.exit(0);
//    	}
                
        return connection;

    }
//    MysqlDataSource ds;
//    public Connection getConnection() {
//        if(connection == null){
//            ds = new MysqlDataSource();
//            ds.setDatabaseName("perpustakaan");
//            try {
//                connection = ds.getConnection("root", "");
//            } catch (SQLException e) {
//                JOptionPane.showMessageDialog(null, "Error when try connect to mysql server, "
//                        + "check your configuration");
//            }
//        }
//        return connection;
//    }
}
